Using a Local Transaction With a DataReader
The following example shows how to use a local transaction with a SequeLinkDataReader object on the SequeLink server Sparky on Oracle.
NOTE: The sample uses the emp table (see "Sample Tables for Oracle"). The Oracle database in this example does not require the Database connection string option.
SequeLinkConnection DBConn; DBConn = new SequeLinkConnection("host=norman;Port=19996;User ID=test01; Password=test01"); SequeLinkCommand DBCmd = new SequeLinkCommand(); SequeLinkTransaction DBTxn = null; try { DBConn.Open(); DBTxn = DBConn.BeginTransaction(); // Set the Connection property of the Command object DBCmd.Connection = DBConn; // Set the text of the Command to the INSERT statement DBCmd.CommandText = "INSERT INTO emp VALUES (15,'HAYES','ADMIN',6, '17-APR-2007',18000,NULL,4)"; // Set the transaction property of the Command object DBCmd.Transaction = DBTxn; // Execute the statement DBCmd.ExecuteNonQuery(); // Now commit the transaction DBTxn.Commit(); } catch (Exception ex) { // Display any exceptions in a messagebox MessageBox.Show (ex.Message); // If anything failed after the connection was opened, roll back the // transaction if (DBTxn != null) { DBTxn.Rollback(); } } // Close the connection DBConn.Close();